﻿using System;

namespace TeslaSamples {
    public class AppItem {
        private Type _type;
        private AppDescriptionAttribute _att;

        public Type AppType {
            get {
                return _type;
            }
        }

        public AppDescriptionAttribute AppAttributes {
            get {
                return _att;
            }
        }

        public AppItem(Type type) {
            _type = type;
            object[] atts = type.GetCustomAttributes(true);
            foreach(Attribute att in atts) {
                AppDescriptionAttribute appAtt = att as AppDescriptionAttribute;
                if(appAtt != null) {
                    _att = appAtt;
                }
            }
        }

        public override string ToString() {
            if(_att != null) {
                return _att.Name;
            } else {
                return _type.ToString();
            }
        }
    }
}
